﻿/*
 * Copyright 2010-2013 Team Robot, Inc.
 * 
 * Author: Peter Coley
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace TeamRobot.Swtor
{
    public enum ZoneType
    {
        None,
        Flashpoint,
        Operation,
        Planet,
    }

    /// <summary>
    /// Describes a zone (flashpoint, operation, planet, etc.).
    /// </summary>
    public class Zone
    {
        public const int UNKOWN = -2;
        public const int TARGET_DUMMY = -1;

        private static readonly Regex _badCharRegex = new Regex(@"[',\.]", RegexOptions.ECMAScript);
        private static readonly Regex _spaceRegex = new Regex(@"[\s]+", RegexOptions.ECMAScript);

        public Zone()
        {
            this.Bosses = new List<Boss>();
        }

        public int Id { get; set; }
        public ZoneType Type { get; set; }
        public string Name { get; set; }

        public string UrlName
        {
            get
            {
                string text = this.Name;
                if (string.IsNullOrEmpty(text)) return "";

                text = text.Trim().ToLowerInvariant();
                text = _badCharRegex.Replace(text, "");
                text = _spaceRegex.Replace(text, "-");
                return text;
            }
        }

        public int Level { get; set; }
        public bool HasHardMode { get; set; }

        /// <summary>
        /// List of bosses in this zone, generally in order by appearance.
        /// </summary>
        public List<Boss> Bosses { get; set; }

        /// <summary>
        /// Lookup of flashpoint/operations by id.
        /// </summary>
        public static readonly Dictionary<int, Zone> FlashpointsById;

        static Zone()
        {
            FlashpointsById = new Dictionary<int, Zone>();
            foreach (Zone zone in Zone.Flashpoints)
                FlashpointsById[zone.Id] = zone;
        }

        /// <summary>
        /// All Flashpoint zones.
        /// </summary>
        public static readonly List<Zone> Flashpoints = new List<Zone>
        {
            new Zone 
            {
                Id = 1,
                Type = ZoneType.Flashpoint,
                Name = "The Esseles",
                Level = 10,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 1, Name = "ISS-7 Guardian Battle Droid" },
                    new Boss { Id = 2, Name = "ISS-994 Power Droid" },
                    new Boss { Id = 3, Name = "Ironfist" },
                    new Boss { Id = 4, Name = "Lieutenant Isric" },
                    new Boss { Id = 5, Name = "Vokk" },
                },
                HasHardMode = true,
            },
            new Zone 
            {
                Id = 2,
                Type = ZoneType.Flashpoint,
                Name = "The Black Talon",
                Level = 10,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 6, Name = "Commander Ghulil" },
                    new Boss { Id = 7, Name = "GXR-5 Sabotage Droid" },
                    new Boss { Id = 8, Name = "GXR-7 Command Droid" },
                    new Boss { Id = 9, Name = "Yadira Ban" },
                },
                HasHardMode = true,
            },
            new Zone 
            {
                Id = 3,
                Type = ZoneType.Flashpoint,
                Name = "Hammer Station",
                Level = 16,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 10, Name = "DN-314 Tunneler" },
                    new Boss { Id = 11, Name = "Vorgan the Volcano" },
                    new Boss { Id = 12, Name = "Battlelord Kreshan" },
                },
            },
            new Zone 
            {
                Id = 4,
                Type = ZoneType.Flashpoint,
                Name = "Athiss",
                Level = 20,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 13, Name = "Professor Ley'arsha" },
                    new Boss { Id = 14, Name = "Prophet of Vodal" },
                    new Boss { Id = 15, Name = "The Beast of Vodal Kressh" },
                },
            },            
            new Zone 
            {
                Id = 5,
                Type = ZoneType.Flashpoint,
                Name = "Mandalorian Raiders",
                Level = 24,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 16, Name = "Braxx the Bloodhound" },
                    new Boss { Id = 17, Name = "Boarding Party" },
                    new Boss { Id = 18, Name = "Mavrix Varad" },
                },
            },            
            new Zone 
            {
                Id = 6,
                Type = ZoneType.Flashpoint,
                Name = "Cademimu",
                Level = 28,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 19, Name = "Officer Xander" },
                    new Boss { Id = 20, Name = "Captain Grimyk" },
                    new Boss { Id = 21, Name = "General Ortol" }, 
                },
            },            
            new Zone 
            {
                Id = 7,
                Type = ZoneType.Flashpoint,
                Name = "Taral V",
                Level = 32,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 22, Name = "Captain Shivanek" },
                    new Boss { Id = 23, Name = "Handler Gattan" },
                    new Boss { Id = 24, Name = "PD-44" },
                    new Boss { Id = 25, Name = "Ripper" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 8,
                Type = ZoneType.Flashpoint,
                Name = "Boarding Party",
                Level = 32,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 26, Name = "HXI-54 Juggernaut" },
                    new Boss { Id = 27, Name = "Sakan Do'nair" },
                    new Boss { Id = 28, Name = "Chief Engineer Kels" },
                    new Boss { Id = 29, Name = "Commander Jorland" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 9,
                Type = ZoneType.Flashpoint,
                Name = "The Foundry",
                Level = 36,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 30, Name = "The Foundry Guardian" },
                    new Boss { Id = 31, Name = "HK-47" },
                    new Boss { Id = 32, Name = "Revan" },
                    new Boss { Id = 33, Name = "Burrower Matriarch" },
                    new Boss { Id = 34, Name = "N4-10 Exterminator" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 10,
                Type = ZoneType.Flashpoint,
                Name = "Maelstrom Prison",
                Level = 36,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 35, Name = "Ancient Maelstrom Flayer" },
                    new Boss { Id = 36, Name = "Colonel Daksh" },
                    new Boss { Id = 37, Name = "Grand Moff Kilran" },
                    new Boss { Id = 38, Name = "Lord Kancras" },
                    new Boss { Id = 39, Name = "Lord Vanithrast" },
                    new Boss { Id = 40, Name = "Mutant Maelstrom Shriek" },
                    new Boss { Id = 41, Name = "X-37 Oppressor Droid" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 11,
                Type = ZoneType.Flashpoint,
                Name = "Colicoid War Game",
                Level = 40,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 42, Name = "Annihilator 6K-A2" },
                    new Boss { Id = 43, Name = "Arena Beast" },
                    new Boss { Id = 44, Name = "Hazard Droid" },
                },
            },            
            new Zone 
            {
                Id = 12,
                Type = ZoneType.Flashpoint,
                Name = "Red Reaper",
                Level = 44,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 45, Name = "Lord Kherus" },
                    new Boss { Id = 46, Name = "SV-3 Eradicator" },
                    new Boss { Id = 47, Name = "Darth Ikoral" },
                },
            },            
            new Zone 
            {
                Id = 13,
                Type = ZoneType.Flashpoint,
                Name = "Directive 7",
                Level = 47,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 48, Name = "Director" },
                    new Boss { Id = 49, Name = "Cyborg" },
                    new Boss { Id = 50, Name = "Assembler" },
                    new Boss { Id = 51, Name = "Interrogator" },
                    new Boss { Id = 52, Name = "Bulwark" },
                    new Boss { Id = 53, Name = "Replicator" },
                    new Boss { Id = 54, Name = "Mentor" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 14,
                Type = ZoneType.Flashpoint,
                Name = "The Battle of Ilum",
                Level = 49,
                Bosses = new List<Boss>
                {
                    new Boss 
                    { 
                        Id = 55, 
                        Name = "Velasu Graege and Drinda-Zel",
                        DeathCriteria = new Dictionary<string, int>
                        {
                            { "Velasu Graege", 1 },
                            { "Drinda-Zel", 1 },
                        }
                    },
                    new Boss { Id = 56, Name = "Krel Thak" },
                    new Boss { Id = 57, Name = "Guid Patriarch" },
                    new Boss { Id = 58, Name = "Darth Serevin" },
                    new Boss { Id = 59, Name = "Gark the Indomitable" },
                    new Boss { Id = 60, Name = "Commander Folex" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 15,
                Type = ZoneType.Flashpoint,
                Name = "The False Emperor",
                Level = 49,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 61, Name = "Jindo Krey" },
                    new Boss { Id = 62, Name = "HK-47" },
                    new Boss { Id = 63, Name = "Tregg the Destroyer" },
                    new Boss { Id = 64, Name = "Darth Malgus" },
                    new Boss 
                    { 
                        Id = 65, 
                        Name = "Prototypes B-16 and A-14",
                        DeathCriteria = new Dictionary<string, int>
                        {
                            { "Prototype B-16", 1 },
                            { "Prototype A-14", 1 }
                        }
                    },
                    new Boss { Id = 66, Name = "Sith Entity" },
                    new Boss { Id = 67, Name = "Chondrus Berani" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 16,
                Type = ZoneType.Flashpoint,
                Name = "Kaon Under Siege",
                Level = 49,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 68, Name = "Waves of Rakghoul" },
                    new Boss { Id = 69, Name = "Rakghoul Behemoth" },
                    new Boss { Id = 70, Name = "KR-82 Expulser" },
                    new Boss { Id = 71, Name = "Commander Lk'Graagth" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 17,
                Type = ZoneType.Operation,
                Name = "The Eternity Vault",
                Level = 50,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 72, Name = "Annihilation Droid XRR-3" },
                    new Boss { Id = 73, Name = "Gharj" },
                    new Boss 
                    { 
                        Id = 74, 
                        Name = "Ancient Pylons",
                        DeathCriteria = new Dictionary<string, int>
                        {
                            { "Rakata Eternal Guard", 100 },
                            { "Rakata Eternal Watcher", 100 },
                            { "Proto Acklay", 100 }, // just a large number for now... don't know how to determine a kill atm
                        }
                    },
                    new Boss 
                    { 
                        Id = 75, 
                        Name = "Infernal Council",
                        DeathCriteria = new Dictionary<string, int>
                        {
                            { "Alarii, Sister of Sorrow", 1 },
                            { "Cyrisop, the Exiled", 1 },
                            { "Fahren Jaj, the Laughing Lord", 1 },
                            { "Keryha, Sister of Sorrow", 1 },
                            { "Luthro the Kinslayer", 1 },
                            { "Wei'val the Elder", 1 },
                            { "Wei'val the Lesser", 1 },
                            { "Doruk, the Uncaged", 1 },
                            { "Jael, the Silencer", 1 },
                            { "Serrod the Messenger", 1 },
                            { "Kahesh, the Reborn", 1 },
                            { "Kyyrah, Jewel of Xo", 1 },
                            { "Jekhop, the Bowed Lord", 1 },
                            { "R'hoteb, the Bowed Lord", 1 },
                            { "Yshaar Kael, Betrayer of Adas", 1 },
                            { "Yshaar the Bowed Lord", 1 },
                            { "Za'heen Kaur, the Bowed Lord", 1 },
                        },
                        DeathCount = new Dictionary<int, int>
                        {
                            { 8, 8 },
                            { 16, 16 },
                        }
                    },
                    new Boss { Id = 76, Name = "Soa" },
                },
                HasHardMode = true,
            },            
            new Zone 
            {
                Id = 18,
                Type = ZoneType.Operation,
                Name = "Karagga's Palace",
                Level = 50,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 77, Name = "Bonethrasher" },
                    new Boss 
                    { 
                        Id = 78, 
                        Name = "Jarg and Sorno",
                        DeathCriteria = new Dictionary<string, int>
                        {
                            { "Jarg", 1 },
                            { "Sorno", 1 },
                        }
                    },
                    new Boss { Id = 79, Name = "Foreman Crusher" },
                    new Boss { Id = 80, Name = "G4-B3 Heavy Fabricator" },
                    new Boss { Id = 81, Name = "Karagga the Unyielding" },
                },
                HasHardMode = true,
            },
            new Zone 
            {
                Id = 19,
                Type = ZoneType.Operation,
                Name = "Explosive Conflict",
                Level = 50,
                Bosses = new List<Boss>
                {
                    new Boss 
                    { 
                        Id = 82, 
                        Name = "Zorn and Toth",
                        DeathCriteria = new Dictionary<string, int>
                        {
                            { "Zorn", 0 },
                            { "Toth", 0 },
                            { "Handler Murdok", 1 },
                        }
                    },
                    new Boss 
                    { 
                        Id = 83, 
                        Name = "Firebrand and Stormcaller", 
                        DeathCriteria = new Dictionary<string, int>
                        {
                            { "Firebrand Battle Tank", 1 },
                            { "Stormcaller Blast Tank", 1 },
                        }
                    },
                    new Boss { Id = 84, Name = "Colonel Vorgath" },
                    new Boss 
                    { 
                        Id = 85, 
                        Name = "Warlord Kephess",
                        DeathCriteria = new Dictionary<string,int>
                        {
                            { "Baradium Bomber", 0 }, // this is here for boss detection
                            { "Warstrider Battlewalker", 0 }, // this is here for boss detection
                            { "Warlord Kephess", 1 },
                        }
                    },
                },
                HasHardMode = true,
            },
            new Zone 
            {
                Id = 20,
                Type = ZoneType.Flashpoint,
                Name = "Lost Island",
                Level = 50,
                Bosses = new List<Boss>
                {
                    new Boss { Id = 86, Name = "LR-5 Sentinel Droid" },
                    new Boss { Id = 87, Name = "Project Sav-Rak" },
                    new Boss { Id = 88, Name = "Transgenic Sample Eleven" },
                    new Boss { Id = 89, Name = "Doctor Lorrick" },
                },
                HasHardMode = true,
            },

            new Zone 
            {
                Id = 21,
                Type = ZoneType.Operation,
                Name = "The Terror From Beyond",
                Level = 50,
                Bosses = new List<Boss>
                {
                    new Boss 
                    { 
                        Id = 90, 
                        Name = "The Writhing Horror",
                        DeathCriteria = new Dictionary<string,int>
                        {
                            { "The Writhing Horror", 1 },
                        }
                    },

                    new Boss 
                    { 
                        Id = 91, 
                        Name = "Ciphas, Heirad, Kel'sara",
                        DeathCriteria = new Dictionary<string,int>
                        {
                            { "Ciphas", 1 }, // need to kill all three
                            { "Heirad", 1 },
                            { "Kel'sara", 1 },
                        }
                    },

                    new Boss 
                    { 
                        Id = 92, 
                        Name = "Operator IX",
                        DeathCriteria = new Dictionary<string,int>
                        {
                            { "Operator IX", 1 }, 
                            { "Recognizer", 0},
                            { "Regulator", 0},
                        }
                    },

                    new Boss 
                    { 
                        Id = 93, 
                        Name = "Kephess the Undying",
                        DeathCriteria = new Dictionary<string,int>
                        {
                            { "Kephess the Undying", 1 }, 
                        }
                    },

                    new Boss 
                    { 
                        Id = 94, 
                        Name = "The Terror from Beyond",
                        DeathCriteria = new Dictionary<string,int>
                        {
                            { "The Terror from Beyond", 1 },
                            { "Tunneling Tentacle", 0 }, // this is here for boss detection
                            { "Grasping Tentacle", 0 }, // this is here for boss detection
                        }
                    },
                },
                HasHardMode = true,
            },
        };
    }
}
